package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4
import com.gitee.wsl.mathematics.base.Mapping2
import com.gitee.wsl.mathematics.base.Mapping3
import com.gitee.wsl.mathematics.base.Mapping4


/** Call [f] on [Vec2.x] and [Vec2.y] components and return it's result. */
 inline fun <T:Number,V: Vector2<T, V>,R> V.reduce(f: Mapping2<T, R>) = f( x, y )

/** Call [f] on [Vec3.x], [Vec3.y], and [Vec3.z] components and return it's result. */
 inline fun <T:Number,V: Vector3<T, V>,R> V.reduce(f: Mapping3<T, R>) = f( x, y, z )

/** Call [f] on [Vec4.x], [Vec4.y], [Vec4.z], and [Vec4.w] components and return it's result. */
 inline fun <T:Number,V: Vector4<T, V>,R> V.reduce(f: Mapping4<T, R>) = f( x, y, z, w )
